gtkscrolledwindow: Look up correctly target in captured motion events
authorCarlos Garnacho <carlosg@gnome.org>
Thu, 9 Jul 2020 14:10:55 +0000 (16:10 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Thu, 9 Jul 2020 14:10:55 +0000 (16:10 +0200)
Check correctly that the captured motion events are emitted towards the
content or one of the scrollbars, in order to have it set the expected
"over" state depending on whether the drag begins from the scrolledwindow
content or one of the scrollbars.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2879
gtk/gtkscrolledwindow.c

index 25312db293c96b67822b2735b38951fd0233db70..bb74c4f17b167c2abbf63807f6ecf882572b7e32 100644 (file)
@@ -1169,10 +1169,13 @@ check_update_scrollbar_proximity (GtkScrolledWindow *sw,
   gboolean indicator_close, on_scrollbar, on_other_scrollbar;
 
   indicator_close = coords_close_to_indicator (sw, indicator, x, y);
-  on_scrollbar = (target == indicator->scrollbar);
+  on_scrollbar = (target == indicator->scrollbar ||
+                  gtk_widget_is_ancestor (target, indicator->scrollbar));
   on_other_scrollbar = (!on_scrollbar &&
                         (target == priv->hindicator.scrollbar ||
-                         target == priv->vindicator.scrollbar));
+                         target == priv->vindicator.scrollbar ||
+                         gtk_widget_is_ancestor (target, priv->hindicator.scrollbar) ||
+                         gtk_widget_is_ancestor (target, priv->vindicator.scrollbar)));
 
   if (indicator->over_timeout_id)
     {
@@ -1262,7 +1265,8 @@ captured_motion (GtkEventController *controller,
   if (priv->vscrollbar_visible)
     indicator_start_fade (&priv->vindicator, 1.0);
 
-  if (!target &&
+  if ((target == priv->child ||
+       gtk_widget_is_ancestor (target, priv->child)) &&
       (state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)) != 0)
     {
       indicator_set_over (&priv->hindicator, FALSE);